﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using MovieRental.Entities;

namespace MovieRental.EfRepositoryLibrary.Mappers
{
    public class CustomerMapper : BaseMapper<CustomerInfo, Guid, Customer, Customer, MovieRentalEntitiesContainer>
    {
        public override void Convert(CustomerInfo entity, Customer model)
        {
            model.Id = entity.Id;
            model.FirstName = entity.FirstName;
            model.LastName = entity.LastName;
            model.Email = entity.Email;
            model.PhoneNo = entity.PhoneNo;
        }

        public override void ConvertBack(Customer model, CustomerInfo entity)
        {
            entity.Id = model.Id;
            entity.FirstName = model.FirstName;
            entity.LastName = model.LastName;
            entity.Email = model.Email;
            entity.PhoneNo = model.PhoneNo;
        }

        public override Guid SelectKey(Customer model)
        {
            return model.Id;
        }

        public override Guid SelectKey(CustomerInfo entity)
        {
            return entity.Id;
        }

        public override ObjectSet<Customer> SelectObjectSet(MovieRentalEntitiesContainer context)
        {
            return context.Customers;
        }
    }
}
